package com.edison.demoservice2.service;

import com.edison.common.BusinessException;
import com.edison.demoservice2.feign.DemoService3;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author edison
 */
@Service
@Slf4j
public class DemoService {

    @Autowired
    private DemoService3 demoService3;

    private static final String ERROR_TYPE = "error";
    public String test(String type)
    {
        log.info("service-2 服务层开始处理业务，type:{}",type);
        log.info("service-2 服务层处理业务结束，type:{}",type);

        if(ERROR_TYPE.equals(type)){

            throw new BusinessException("service-2 内部处理异常。");

        }
        log.info("service-2 尝试调用 service-3 继续处理业务");
        return  demoService3.test(type);
    }
}
